package com.xd.clap.controller;


import com.xd.clap.entity.Advise;
import com.xd.clap.entity.request.AdviseParam;
import com.xd.clap.entity.request.PageParam;
import com.xd.clap.entity.response.Result;
import com.xd.clap.services.AdviseService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/advise")
public class AdviseController {

    @Resource
    private AdviseService as;

    /**
     * 上传意见
     */
    @PostMapping("/uploadAdvise")
    public Result uploadAdvise(@RequestBody AdviseParam adviseParam){
        return as.uploadAdvise(adviseParam);
    }

    /**
     * 分页查询意见
     */
    @PostMapping("/getAdvisePage")
    public Result getAdvisePage(@RequestBody PageParam pageParam){
        return as.getAdvisePage(pageParam);
    }

    /**
     * 分页查询意见
     */
    @PostMapping("/getAdvisePageCode")
    public Result getAdvisePageCode(@RequestBody PageParam pageParam){
        return as.getAdvisePageCode(pageParam);
    }

    /**
     * 通过ID驳回误报建议
     */
    @PostMapping("/rejectedAdvise")
    public Result rejectedAdvise(@RequestBody AdviseParam adviseParam){
        return as.rejectedAdvise(adviseParam.getId());
    }

    /**
     * 分配辖区负责人
     */
    @PostMapping("/sentAddress")
    public Result sentAddress(@RequestBody AdviseParam adviseParam){
        return as.sentAddress(adviseParam);
    }

    /**
     * 查询催办意见
     */
    @PostMapping("/getUrgeAdvise")
    public Result getUrgeAdvise(@RequestBody PageParam pageParam){
        return as.getUrgeAdvise(pageParam);
    }

    /**
     * 催促办理事件
     */
    @PostMapping("/urgeAdvise")
    public Result urgeAdvise(@RequestBody List<Advise> adviseList){
        return as.urgeAdvise(adviseList);
    }


    /**
     * 获取各建议状态统计数量
     */
    @PostMapping("/getStateCount")
    public Result getStateCount(@RequestBody AdviseParam adviseParam){
        return as.getStateCount(adviseParam.getFirstAddress());
    }

    /**
     * 获取最新十条建议
     */
    @PostMapping("/getAdviseList")
    public Result getAdviseList(@RequestBody AdviseParam adviseParam){
        return as.getAdviseList(adviseParam.getFirstAddress());
    }

    /**
     * 获取地图和排行统计数量
     */
    @PostMapping("/getMapRankData")
    public Result getMapRankData(){
        return as.getMapRankData();
    }

    /**
     * 获取最近七天建议上报统计
     */
    @PostMapping("/getLatelyData")
    public Result getLatelyData(){
        return as.getLatelyData();
    }


    /**
     * 更新事件积分
     */
    @PostMapping("/updateRate")
    public Result updateRate(@RequestBody Advise advise){
        return as.updateRate(advise);
    }


    /**
     * 删除某个建议
     * @param adviseId
     * @return
     */
    @GetMapping("/deleteAdvise")
    public Result deleteAdvise(@Validated Integer adviseId){
        return as.deleteAdvise(adviseId);
    }

}
